import axios from "./http"

// console.log(process.env.NODE_ENV);


// 登录
var postLogin = params => axios.post('/login', params);



// 请求侧边栏数据
var getMenus = params => axios.get(`/menus`, params)
// 获取权限列表
var getRights = params => axios.get(`/rights/` + params.type)




// 获取用户列表
var getUsers = params => axios.get('/users', params)
// 添加用户
var postAddUser = params => axios.post('/users', params);
// 根据 ID 查询用户信息
var getUserInfo = params => axios.get('/users/' + params.id)
// 分配用户角色
var putUserRole = params => axios.put(`/users/${params.id}/role`, params)
// 更改用户状态
var putUserStatus = params => axios.put(`/users/${params.id}/state/${params.status}`)
// 删除用户
var deleteUser = params => axios.delete(`/users/${params.id}`)
// 编辑用户信息
var puteditUser = params => axios.put(`/users/${params.id}`, params)



// 获取角色列表
var getUserRoles = params => axios.get('/roles', params)
// 删除角色指定权限
var deleteJokerRoles = params => axios.delete(`/roles/${params.roleId}/rights/${params.rightId}`)
// 添加角色
var postAddJoker = params => axios.post('/roles', params)
// 编辑角色信息
var puteditJoker = params => axios.put(`/roles/${params.id}`, params)
// 删除角色
var deleteJoker = params => axios.delete(`/roles/${params.id}`)
// 角色分配权限
var postJokerRoles = params => axios.post(`roles/${params.id}/rights`, params)


// 获取商品列表
var getGoodsList = params => axios.get('/goods', params)
// 添加商品
var postaddGoods = params => axios.post('/goods', params)
// 根据ID查询商品
var getsearchGoods = params => axios.get('/goods/' + params.id)
// 编辑提交商品
var puteditGoods = params => axios.put(`/goods/${params.id}`, params)
// 删除商品
var deleteGoods = params => axios.delete(`/goods/${params.id}`)



// 获取订单列表
var getOrdersList = params => axios.get('/orders', params)
// 根据ID查询商品
var getsearchGoods = params => axios.get('/goods/' + params.id)
// 修改订单状态
var puteditOrders = params => axios.put(`/orders/${params.id}`, params)
// 删除商品
var deleteGoods = params => axios.delete(`/goods/${params.id}`)



// 获取商品分类数据
var getCategories = params => axios.get('/categories', params)
// 添加分类
var postaddCategories = params => axios.post('/categories', params)
// 删除分类
var deleteCategories = params => axios.delete(`/categories/${params.id}`)
// 编辑提交参数
var puteditCategories = params => axios.put(`/categories/${params.id}`, params)



// 获取参数列表
var getCateAttrs = params => axios.get(`categories/${params.id}/attributes`, { params })
// 添加参数属性
var postCateAttrs = params => axios.post(`categories/${params.id}/attributes`, params)
// 编辑参数
const putCateAttrs = params => axios.put(`/categories/${params.id}/attributes/${params.attr_id}`, params);

// 删除参数
const deleteCateAttrs = params => axios.delete(`/categories/${params.id}/attributes/${params.attr_id}`, params);


// 获取数据报表
var getReports = params => axios.get('reports/type/1', params)


// 上传图片
const uploadUrl = axios.defaults.baseURL + "/upload";

var postupload = params => axios.post(`upload`, params)

export {
    postLogin,
    getUserInfo,
    putUserRole,
    getMenus,
    getRights,
    getUsers,
    postAddUser,
    putUserStatus,
    deleteUser,
    getUserRoles,
    deleteJokerRoles,
    postAddJoker,
    puteditUser,
    puteditJoker,
    deleteJoker,
    postJokerRoles,
    getGoodsList,
    postaddGoods,
    puteditGoods,
    deleteGoods,
    getsearchGoods,
    getOrdersList,
    puteditOrders,
    getCategories,
    deleteCategories,
    postaddCategories,
    puteditCategories,
    getReports,
    getCateAttrs,
    postCateAttrs,
    putCateAttrs,
    deleteCateAttrs,
    postupload,
    uploadUrl
}
